Skip to main content

Developer API

CocoEOTW provides a comprehensive API for developers to integrate with the plugin.

Getting the APIโ€‹

import me.upoka.cocoeotw.api.CocoEOTWAPI;

// Check if plugin is available
if (CocoEOTWAPI.isAvailable()) {
CocoEOTWAPI api = CocoEOTWAPI.getInstance();
// Use the API
}

Maven Dependencyโ€‹

<repository>
<id>jitpack.io</id>
<url>https://repo.cocostudios.net</url>
</repository>

<dependency>
<groupId>net.cocostudios.CocoStudios</groupId>
<artifactId>CocoEOTW</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>

Event State Methodsโ€‹

Check EOTW Statusโ€‹

// Check if EOTW is active
boolean isActive = api.isEotwActive();

// Check if waiting phase is active
boolean isWaiting = api.isWaitingActive();

// Check if any event is active
boolean eventActive = api.isEventActive();

Control EOTWโ€‹

// Start/Stop EOTW
api.startEotw();
api.stopEotw();

// Start/Stop Waiting Phase
api.startWaiting();
api.stopWaiting();

Player Managementโ€‹

Alive/Dead Statusโ€‹

// Check if player is alive
boolean alive = api.isPlayerAlive(player);
boolean dead = api.isPlayerDead(player);

// Set player status
api.setPlayerDead(player);
api.setPlayerAlive(player);

// Get alive players
List<Player> alivePlayers = api.getAlivePlayers();
int aliveCount = api.getAlivePlayersCount();

Kill Trackingโ€‹

// Get player kills
int kills = api.getPlayerKills(player);

// Add a kill
api.addKill(killer);
api.addKill(killerUUID);

// Clear all kills
api.clearAllKills();

Team Managementโ€‹

Team Informationโ€‹

// Get player's team
String team = api.getTeamByPlayer(player);
String displayName = api.getTeamDisplayName(player);
boolean hasTeam = api.hasTeam(player);

// Team status
boolean teamAlive = api.isTeamAlive(team);
boolean playerTeamAlive = api.isPlayerTeamAlive(player);

// Team members
List<Player> members = api.getTeamMembers(team);
List<Player> membersByName = api.getTeamMembersByName("Warriors");

// Team kills
int teamKills = api.getTeamKills(team);

Alive Teamsโ€‹

// Get alive teams
List<String> aliveTeams = api.getAliveTeams();
int aliveTeamsCount = api.getAliveTeamsCount();
int teamsWithPlayers = api.getAliveTeamsCountWithSoloPlayers();

// Players without team
List<Player> soloPlayers = api.getAlivePlayersWithoutTeam();

Bounty & Eventsโ€‹

Bounty Eventโ€‹

// Check bounty status
boolean bountyActive = api.isBountyActive();
Player target = api.getBountyTarget();

// Control bounty
api.startBounty(targetPlayer);
api.stopBounty();

First Kill Eventโ€‹

// Check first kill status
boolean firstKillActive = api.isFirstKillActive();

// Control first kill
api.startFirstKill();
api.stopFirstKill();

World Borderโ€‹

// Get current border size
int size = api.getBorderSize();

// Set border size
api.setBorderSize(world, 500, 60); // 500 blocks over 60 seconds
api.setBorderSizeInstant(world, 100); // Instant change

Vanish Systemโ€‹

// Check if player is vanished
boolean vanished = api.isVanished(player);

// Set vanish status
api.setVanished(player, true);
api.setVanished(player, false);

// Spectator team (visual)
api.applySpectatorTeam(player);
api.removeSpectatorTeam(player);

Death Inventory Storageโ€‹

// Store death inventory
api.storeDeathInventory(player, inventory, armor, offhand, location);
api.storeDeathInventoryAsync(player, inventory, armor, offhand, location);

// Get death inventory
DeathInventoryData data = api.getDeathInventory(uuid);
CompletableFuture<DeathInventoryData> dataFuture = api.getDeathInventoryAsync(uuid);

// Remove death inventory
api.removeDeathInventory(uuid);
api.removeDeathInventoryAsync(uuid);

// Reset all
api.resetDeathInventories();

Toplistโ€‹

// Get top teams
List<String> topTeams = api.getTopTeams();
List<String> topTeamNames = api.getTopTeamsDisplayNames();

// Get specific position
String firstPlace = api.getTopTeam(1);
String firstName = api.getTopTeamDisplayName(1);

// Reset toplist
api.resetToplist();

Utility Methodsโ€‹

Teleportation (Folia Compatible)โ€‹

api.teleportPlayer(player, location);
api.teleportPlayer(player, targetPlayer);
api.runOnPlayerRegion(player, () -> {
// Code runs on player's region
});

// Check if Folia
boolean isFolia = api.isFolia();

Task Schedulingโ€‹

// Run tasks
api.runTask(() -> { /* sync */ });
api.runTaskAsync(() -> { /* async */ });
api.runTaskLater(() -> { /* delayed */ }, 20L);
api.runTaskLaterAsync(() -> { /* delayed async */ }, 20L);
api.runTaskTimer(() -> { /* repeating */ }, 0L, 20L);
api.runTaskTimerAsync(() -> { /* repeating async */ }, 0L, 20L);

Broadcastingโ€‹

api.broadcast("Message to all");
api.broadcastToAlivePlayers("Message to alive players");
api.broadcastToDeadPlayers("Message to dead players");
api.broadcastToTeam("Warriors", "Message to team");

Configuration Accessโ€‹

String message = api.getConfigMessage("messages.no_permission");
String value = api.getConfigString("settings.spawn.location");
int number = api.getConfigInt("settings.revive.delay", 5);
boolean enabled = api.getConfigBoolean("settings.elytra.enabled");
List<String> list = api.getConfigStringList("settings.start.commands.commands");

// Reload configuration
api.reloadConfig();

Example: Custom Event Listenerโ€‹

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import me.upoka.cocoeotw.api.CocoEOTWAPI;

public class MyEOTWListener implements Listener {

@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
if (!CocoEOTWAPI.isAvailable()) return;

CocoEOTWAPI api = CocoEOTWAPI.getInstance();

// Only process during EOTW
if (!api.isEotwActive()) return;

Player victim = event.getEntity();
Player killer = victim.getKiller();

if (killer != null) {
// Custom kill reward
int kills = api.getPlayerKills(killer);
if (kills >= 10) {
killer.sendMessage("ยง6You've reached 10 kills!");
}
}

// Check remaining players
int remaining = api.getAlivePlayersCount();
if (remaining <= 3) {
api.broadcast("ยงcOnly " + remaining + " players remaining!");
}
}
}